//this

//1) new keyword -- created an empty Object , this is instance of that function
//2) with out new inside a function -- this is a window object
//3) in a object literal , this refers to the object itself
//4) call and apply

function Person(name){
   //this
    this.name = name
    //return this
}
var john = new Person('John');
//john instanceOf Person // true
var jim = Person('jim')
window.name = 'jim';

var person = {
    name : 'john',
    CapitalName : function(lastName,middleName){
        var fName = this.name + middleName + lastName;
        return fName.toUpperCase();
    }
}
var animal = {
    name : 'jirafee',
    capitalName : function(){
        return this.name.substr(0,2);//0 and count 2 chars
    }
};
person.capitalName('batson','J');// 'JOHN'
person.capitalName.call(animal,'batson', 'J');// JIRAFEE
var names = ['batson', 'J'];
person.capitalName.apply(animal,names);//JIRAFEE
//call and apply

//function










